<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="form1">
    申请者用户id:<input type="text" name="user_id">
    <br>
    资源id:
    <input type="text" name="resource_id">
    <br>
    资源所属用户的id：
    <input type="text" name="resource_user_id">
    <br>
    <input type="button" value="申请" id="btn">

</form>
<hr>
<p>公开的资源</p>
<a href="/user/api/1/?username=heyin">1不存在</a>
<br>
<a href="/user/api/2/?username=heyin">2公开存在</a>
<br>
<a href="/user/api/2/?username=hey">2公开存在,参数错误</a>
<br>
<a href="/user/api/2/?username=heyin&token=jdfkalkf">2公开存在,有多余参数</a>
<br>
<a href="/user/api/4/?username=heyin">4非公开存在，参数错误</a>
<br>
<a href="/user/api/23/?username=heyin&token=2d6cd089-f760-40d6-9193-d00ce895b1c6">23非公开存在，参数正确</a>
<br>
<a href="/user/api/23/?username=hey&token=2d6cd089-f760-40d6-9193-d00ce895b1c6">23非公开存在，用户名错误</a>
<br>
<a href="/user/api/23/?username=heyin&token=6cd089-f760-40d6-9193-d00ce895b1c6">23非公开存在，token错误</a>

<script src="/static/jquery/jquery.min.js"></script>
<script src="/static/js/set_csrf_async.js"></script>
<script>
    $('#btn').on('click', function () {
        var t = $('form1').serializeArray();

        $.ajax({
            type: 'post',
            url: '/user/resource/',
            data: t,
            dataType: 'json',
            success: function (data) {
                if (data.code === 0) {
                    layer.msg(data.msg, {
                        icon: 6, time: 2000, end: function () {
                            {#                            location.href = '/user/resource/review/0/'#}
                        }
                    });
                } else {
                    layer.alert(data.msg)
                }
            }
        })
    })
</script>
</body>
</html>